<?php
class Errorpage {
	public function show($e) {
		// When there is a custom error page then load it.
		if(file_exists(CONFIG_APP . 'views/errorpages/'. $e->getCode() . '.errorpage.php')) {
			include(CONFIG_APP . 'views/errorpages/'. $e->getCode() . '.errorpage.php');
			return;
		}
		// If there is no custom error page with this code than load the default.
		if(file_exists(dirname(__FILE__).'/../errorpages/'.$e->getCode().'.errorpage.php')) {
			include(dirname(__FILE__).'/../errorpages/'.$e->getCode().'.errorpage.php');
			return;
		} 
		// If there is errorpage at all, display the error.
		echo 'ERROR ' . $e->getCode() . ': '.$e->getMessage();
	}
}
?>